package com.big.app.config;


import io.swagger.annotations.Api;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration //标记 这是一个配置类
@EnableSwagger2 //开启Swagger接口文档
public class SwaggerConfig {
    @Bean //等同于 <bean>  IOC创建类的对象，修饰方法，把方法的
    public Docket createDocket(){
        //设置Swagger的信息
        return new Docket(DocumentationType.SWAGGER_2).apiInfo(createApi()).select()
                .apis(RequestHandlerSelectors.withClassAnnotation(Api.class)).build();
    }
    //创建接口文档信息
    public ApiInfo createApi(){
        return new ApiInfoBuilder().title("接口文档名称").description("接口文档的描述信息").
                contact(new Contact("周围","http://www.qfedu.com","zw@163.com")).
                build();
    }
}